<%--
    Created on : 2019
    Author     : 黄忠
--%>

<%@ page import="java.util.stream.StreamSupport" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page errorPage="error.jsp" %>
<html>
<head>
    <title>登录信息验证</title>
</head>
<body>
<jsp:useBean id="userBean" scope="session" class="Bean.UserBean"/>
<jsp:setProperty name="userBean" property="userName" param="userName"/>
<jsp:setProperty name="userBean" property="password" param="password"/>
<%
    if(session.getAttribute("UserBean")!=null) response.sendRedirect("http://localhost:8080/infor.jsp");
    else if(!userBean.check()) {
        System.out.println("登录失败");
        response.getWriter().write("<script>alert('用户名或密码错误!');location.href='http://localhost:8080/login.jsp'</script>");
    }
    else {
        System.out.println("登录成功");
        session.setAttribute("UserBean",userBean);
        response.sendRedirect("http://localhost:8080/infor.jsp");
    }
%>
</body>
</html>
